################################################################################################
# Balance Check

t.fem <- t.test(data$fem ~ data$rel_banperm, var.equal=F)
t.age <- t.test(data$age ~ data$rel_banperm, var.equal=F)
t.edu <- t.test(data$edu_high ~ data$rel_banperm, var.equal=F)
t.ide <- t.test(data$leftright ~ data$rel_banperm, var.equal=F)
t.sub <- t.test(data$religiosity ~ data$rel_banperm, var.equal=F)

t.mus <- t.test(data$rel_muslim ~ data$rel_banperm, var.equal=F)
t.chr <- t.test(data$rel_christ ~ data$rel_banperm, var.equal=F)

t.non <- t.test(data$rel_nonpract ~ data$rel_banperm, var.equal=F)
t.dev <- t.test(data$rel_devote ~ data$rel_banperm, var.equal=F)
t.rad <- t.test(data$rel_funda ~ data$rel_banperm, var.equal=F)


t.bul <- t.test(data$rel_bulgaria ~ data$rel_banperm, var.equal=F)
t.nig <- t.test(data$rel_nigeria ~ data$rel_banperm, var.equal=F)
t.bri <- t.test(data$rel_britain ~ data$rel_banperm, var.equal=F)

balance.tab <- rbind(
  c(round(t.fem$estimate, 3), round(t.fem$estimate[2]-t.fem$estimate[1],3),  round(t.fem$p.value, 2)),
  c(round(t.age$estimate, 3), round(t.age$estimate[2]-t.age$estimate[1],3),  round(t.age$p.value, 2)),
  c(round(t.edu$estimate, 3), round(t.edu$estimate[2]-t.edu$estimate[1],3),  round(t.edu$p.value, 2)),
  c(round(t.ide$estimate, 3), round(t.ide$estimate[2]-t.ide$estimate[1],3),  round(t.ide$p.value, 2)),
  c(round(t.sub$estimate, 3), round(t.sub$estimate[2]-t.sub$estimate[1],3),  round(t.sub$p.value, 2)),
  
  c(round(t.mus$estimate, 3), round(t.mus$estimate[2]-t.mus$estimate[1],3),  round(t.mus$p.value, 2)),
  c(round(t.chr$estimate, 3), round(t.chr$estimate[2]-t.chr$estimate[1],3),  round(t.chr$p.value, 2)),
  
  c(round(t.non$estimate, 3), round(t.non$estimate[2]-t.non$estimate[1],3),  round(t.non$p.value, 2)),
  c(round(t.dev$estimate, 3), round(t.dev$estimate[2]-t.dev$estimate[1],3),  round(t.dev$p.value, 2)),
  c(round(t.rad$estimate, 3), round(t.rad$estimate[2]-t.rad$estimate[1],3),  round(t.rad$p.value, 2)),
  
  c(round(t.bul$estimate, 3), round(t.bul$estimate[2]-t.bul$estimate[1],3),  round(t.bul$p.value, 2)),
  c(round(t.nig$estimate, 3), round(t.nig$estimate[2]-t.nig$estimate[1],3),  round(t.nig$p.value, 2)),
  c(round(t.bri$estimate, 3), round(t.bri$estimate[2]-t.bri$estimate[1],3),  round(t.bri$p.value, 2))
)

colnames(balance.tab) <- c("Restrictive", "Liberal", "Diff", "p-value")
rownames(balance.tab) <- c("female", "age", "educ", "leftright", "religiosity", "muslim", "christian", "non", "devout", "radical", "bulgaria", "nigeria", "native")





